package com.sunnay.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sunnay.entity.AutoDeliveryOrderEntity;
import com.sunnay.mapper.AutoDeliveryOrderMapper;
import com.sunnay.service.AutoDeliveryOrderService;
import com.sunnay.vo.auth.SystemUser;
import org.springframework.stereotype.Service;

@Service
public class AutoDeliveryOrderServiceImpl extends ServiceImpl<AutoDeliveryOrderMapper, AutoDeliveryOrderEntity> implements AutoDeliveryOrderService {

    @Override
    public void submitReceive(SystemUser systemUser) {
        AutoDeliveryOrderEntity orderEntity = this.getOne(Wrappers.<AutoDeliveryOrderEntity>query().lambda().eq(AutoDeliveryOrderEntity::getWxId,systemUser.getWxId()));
        if(ObjectUtil.isEmpty(orderEntity)){
            orderEntity = new AutoDeliveryOrderEntity();
            orderEntity.setStatus("0");
            orderEntity.setWxId(systemUser.getWxId());
            this.save(orderEntity);
        }else{
            orderEntity.setStatus("0");
            this.updateById(orderEntity);
        }
    }
}
